#!/bin/sh
true \
&& bisonfull=bison-2.5 \
&& cmakefull=cmake-2.8.12.2 \
&& ncursesfull=ncurses-5.8 \
&& mysqlfull=mysql-5.5.38 \
&& pkgsrc=/root/install/mysql/ \
&& tgtdir="/usr/local" \
&& rm -fr ${tgtdir}/${bisonfull} ${tgtdir}/${cmakefull} ${tgtdir}/${ncursesfull} ${tgtdir}/${mysqlfull} \
&& rm -fr ${pkgsrc}/${bisonfull} ${pkgsrc}/${cmakefull} ${pkgsrc}/${ncursesfull} ${pkgsrc}/${mysqlfull} \
&& pkgfull="${bisonfull}" && tar -zxf "${pkgsrc}/${pkgfull}.tar.gz" -C "${pkgsrc}" && cd "${pkgsrc}/${pkgfull}" \
&& ./configure --prefix="/usr/local/${bisonfull}" && make && make install \
&& pkgfull="${cmakefull}" && tar -zxf "${pkgsrc}/${pkgfull}.tar.gz"  -C "${pkgsrc}" && cd "${pkgsrc}/${pkgfull}" \
&& ./configure --prefix="/usr/local/${cmakefull}" && make && make install \
&& pkgfull="${ncursesfull}" && tar -zxf "${pkgsrc}/${pkgfull}.tar.gz" -C "${pkgsrc}"  && cd "${pkgsrc}/${pkgfull}" \
&& ./configure --prefix=/usr/local/${ncursesfull} && make && make install \
&& export PATH=$PATH:/usr/local/${cmakefull}/bin/ \
&& export PATH=$PATH:/usr/local/${ncursesfull}/bin/ \
&& export PATH=$PATH:/usr/local/${bisonfull}/bin/ \
&& export CMAKE_LIBRARY_PATH=$CMAKE_LIBRARY_PATH:/usr/local/${ncursesfull}/lib/ \
&& export CMAKE_INCLUDE_PATH=$CMAKE_LIBRARY_PATH:/usr/local/${ncursesfull}/include/ \
&& pkgfull="${mysqlfull}" && tar -zxf "${pkgsrc}/${pkgfull}.tar.gz"  -C "${pkgsrc}" && cd "${pkgsrc}/${pkgfull}" \
&& cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/${mysqlfull} -DINSTALL_DATADIR=/usr/local/${mysqlfull}/data \
&& make && make install \
&& pw groupadd mysql && pw useradd mysql -g mysql \
&& chown -R mysql /usr/local/${mysqlfull} && chgrp -R mysql /usr/local/${mysqlfull} \
&& cd /usr/local/${mysqlfull} && /usr/local/${mysqlfull}/scripts/mysql_install_db --user=mysql \
&& true
# /usr/local/mysql/bin/mysqld_safe:25:user='mysql'
# so if use os user : userA/groupA, not mysql/mysql. should modify /usr/local/mysql/bin/mysqld_safe
# && groupadd mysql && useradd -r -g mysql mysql \